package com.twu.biblioteca;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: aulme
 * Date: 28/06/2013
 * Time: 10:26
 * To change this template use File | Settings | File Templates.
 */
public class MenuOptions {
    private UserInterface userInterface;
    private List<Option> options;

    public MenuOptions(UserInterface mockUi, List<Option> options) {
        this.userInterface = mockUi;
        this.options = options;
    }

    public void showOptions() {
        this.userInterface.showMessage("Options available:");
        for (int i = 0; i < this.options.size(); i++) {
            this.userInterface.showMessage((i + 1) + ") " + this.options.get(i).toString());
        }
    }

    public void invokeOption(int optionNumber) {
        if (optionNumber >= this.options.size() || optionNumber < 0) {
            this.userInterface.showMessage("Select a valid option!!");
            return;
        }

        this.options.get(optionNumber).Execute();
    }
}
